Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
This PR modifies 2 lines of
plot.pedigree()
, fixing a minor bug affecting the vertical scaling. The problem is most visible when plotting small pedigrees with multiline labels:Created on 2022-09-15 with reprex v2.0.2
As seen, the symbols are vertically squished, and the pedigree does not fill the plot region. This is caused by the following line in the source code, where the
usr
parameter is set:kinship2/R/plot.pedigree.R
Lines 154 to 155 in 0a0dbd3
In the third entry,
maxlev
andboxh
are correctly given in user coordinates, but thestemp3
andstemp2
terms are not -- they should be divided byvscale
.Furthermore, I believe that
vscale
is slightly miscalculated:kinship2/R/plot.pedigree.R
Line 149 in 0a0dbd3
As I understand it, the term
stemp2/2
(both here and in theusr
vector) is meant to account for the vertical gap between the symbol and the label. But this gap is actuallystemp2 * 0.7
(i.e.,labh * 0.7
after scaling):kinship2/R/plot.pedigree.R
Line 271 in 0a0dbd3
Thus, the factor 1/2 is too small, sometimes allowing the label to go below the plot region. I suggest to simply remove it, which ensures a tiny amount of white space below the label.
Here is the same example plotted with the suggested changes:
Created on 2022-09-15 with reprex v2.0.2
Thanks for maintaining this useful package!
Magnus